package com.hb.trade.server.center.sys.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hb.core.pojo.center.sys.entity.NewsCenter;
import com.hb.core.pojo.center.sys.mapper.NewsCenterMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hb.core.pojo.enums.RoleSignEnum;
import com.hb.core.pojo.parent.MPCommonEntity;
import com.hb.trade.server.center.sys.service.NewsCenterService;
import org.fzzn.core.util.Enums;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 消息中心 服务实现类
 * </p>
 *
 * @author zhongdl
 * @since 2022-02-18
 */
@Service
public class NewsCenterServiceImpl extends ServiceImpl<NewsCenterMapper, NewsCenter> implements NewsCenterService {
    /**
     *
     * @Description: 获得读和未读的状态个数(传null则为全部)
     * @Author: zhongdl
     * @Date:2022/2/18 17:10
     * @param receiverId:
     * @param readFlag:
     * @return: {@link int }
     **/
    @Override
    public long readFlagCount(Long receiverId, Integer readFlag,Integer roleSign) {
        QueryWrapper<NewsCenter> wrapper = NewsCenter.wrapper();
        wrapper.eq("receiver_id",receiverId)
                .eq(readFlag != null ,"read_flag",readFlag)
                .in(Enums.equals(RoleSignEnum.TENDEREE,roleSign),"news_type_two", CollUtil.list(false,3,4,6,8,9,13))
                .in(Enums.equals(RoleSignEnum.BIDDER,roleSign),"news_type_two",CollUtil.list(false,1,2,3,5,7,10,11,12,14))
                .in(Enums.equals(RoleSignEnum.AGENCY,roleSign),"news_type_two",CollUtil.list(false,3,4,6,8,9,13));
        return count(wrapper);
    }
}
